<?php require_once("header.php");?>   
<?php require_once("php/carousel.php");?>   
<?php $recipes = json_decode(api("all_recipes/".$user_id,"GET",null),true);?> 

<input id="add_recipe" type="button" onClick="window.location='add-recipe.php'" value="Add a New Recipe" />   

<br />
<input type="text" class="tags filter" placeholder="Filter by tags or ingredients. (ex: Breakfast, Kid Friendly, Sandwich)" />
<input id="filter" type="button" value="Filter Recipes" />

<?php displayCarousel($recipes,"user","Your Recipes",$user_id);?>

<?php $favorites = json_decode(api("favorites/".$user_id,"GET",null),true);?>
<?php displayCarousel($favorites,"favorites","Your Favorite Recipes",NULL);?>

<?php displayCarousel($recipes,"others","Friends' & Public Recipes",$user_id);?>

<script>
setFilter();

// tags
<?php $tags = api("tags/","GET",null);?>
var tempTags = <?php echo $tags;?>;
var tags = new Array();
for(var i=0; i<tempTags.length; i++){
	tags[i] = tempTags[i]['name'];;
}

// ingredients
<?php $ingredients = api("ingredients/","GET",null);?>
var tempIngredients = <?php echo $ingredients;?>;
var ingredients = new Array();
for(var i=0; i<tempIngredients.length; i++){
	ingredients[i] = tempIngredients[i]['name'];;
}

var combined = tags.concat(ingredients);
setAutoComplete("tags",false,combined,true);
submitOnEnter(".filter",filter);
</script>

<?php require_once("footer.php");?>    